import request from "@/utils/request.js"

export const login = data => {
    return request({
      method: 'POST',
      url: '/v1_0/authorizations',
      data
    })
  }

export function sendMsm(mobile) {
    return request({
        method: 'GET',
        url: '/v1_0/sms/codes/' + mobile
    })
}

export function getUserInfo() {
    return request({
        method: 'GET',
        url: '/v1_0/user'
    })
}
// 获取用户个人资料 编辑时用的
export function getUserProfile() {
    return request({
        method: 'GET',
        url: '/v1_0/user/profile'
    })
}

export function editUserInfo(data) {
    return request({
        method: 'PATCH',
        url: '/v1_0/user/profile',
        data
    })
}
export function getUserChannels() {
    return request({
        method: 'GET',
        url: '/v1_0/user/channels'
    })
}

export function getAllChannels() {
    return request({
        method: 'GET',
        url: '/v1_0/channels'
    })
}

// 修改指定用户频道
export function editUserChannels(data) {
    return request({
        method: 'PUT',
        url: '/v1_0/user/channels/' + data.id,
        data
    })
}

// 删除用户频道列表
export function delUserChannels(id) {
    return request({
        method: 'DELETE',
        url: '/v1_0/user/channels/' + id
    })
}

// 取消关注
export function cancelFollow(id) {
    return request({
        method: 'DELETE',
        url: '/v1_0/user/followings/' + id
    })
}

// 关注用户
export function toFollow(target) {
    return request({
        method: 'POST',
        url: '/v1_0/user/followings',
        data: {
            target
        }
    })
}

// 收藏文章
export function toCollect(target) {
    return request({
        method: 'POST',
        url: '/v1_0/article/collections',
        data: {
            target
        }
    })
}
// 取消收藏
export function cancelCollect(id) {
    return request({
        method: 'DELETE',
        url: 'v1_0/article/collections/' + id
    })
}

// 取消点赞
export function cancelLike(id) {
    return request({
        method: 'DELETE',
        url: '/v1_0/article/likings/' + id
    })
}

// 点赞
export function toLike(id) {
    return request({
        method: 'POST',
        url: '/v1_0/article/likings',
        data: {
          target: id
        }
    })
}

// 上传头像
export function uploadPhoto(data) {
    return request({
        method: 'PATCH',
        url: '/v1_0/user/photo',
        data
    })
}
// 获取关注列表
export function getFollowList(params, data) {
    return request({
        method: 'GET',
        url: '/v1_0/user/followings',
        params,
        data
    })
}

// 获取粉丝列表
export function getFansList(params, data) {
    return request({
        method: 'GET',
        url: '/v1_0/user/followers',
        params,
        data
    })
}

